package com.youku.core
{
   import flash.display.MovieClip;
   import com.youku.interfaces.IPlayerProxy;
   import com.youku.core.view.CoreMediator;
   import com.youku.core.model.PlayListProxy;
   import com.youku.events.CoreFacadeEvent;
   import com.youku.events.PlayerControlEvent;
   
   public class CoreFacade extends Object
   {
      
      public function CoreFacade() {
         super();
      }
      
      private static var _instance:CoreFacade;
      
      private static var _mainMc:MovieClip;
      
      private static var _playerProxy:IPlayerProxy;
      
      public static function getInstance() : CoreFacade {
         if(_instance == null)
         {
            _instance = new CoreFacade();
         }
         return _instance as CoreFacade;
      }
      
      private var _coreMediator:CoreMediator;
      
      private var _playListProxy:PlayListProxy;
      
      public function init(param1:MovieClip, param2:IPlayerProxy) : void {
         _mainMc = param1;
         _playerProxy = param2;
         _playerProxy.addEventListener(CoreFacadeEvent.LOAD_PLAY_LIST_DATA,this.onCoreFacadeEvent);
         _playerProxy.addEventListener(PlayerControlEvent.COMMON_RESET,this.onCommonReset);
         this._coreMediator = new CoreMediator(_mainMc,_playerProxy);
         this._coreMediator.init();
      }
      
      private function onCommonReset(param1:PlayerControlEvent) : void {
         this._playListProxy.close();
      }
      
      private function onCoreFacadeEvent(param1:CoreFacadeEvent) : void {
         var _loc2_:String = null;
         if((param1.data) && !(param1.data.othervid == null))
         {
            _loc2_ = param1.data.othervid;
         }
         this._playListProxy = new PlayListProxy(_playerProxy);
         this._playListProxy.init(_loc2_);
      }
   }
}
